package com.clkj.cldisabledmanclient.util;

import android.content.Context;
import android.widget.Toast;


/**
 * Created by Administrator on 2015/8/13.
 */
public class ToastUtil {

    private ToastUtil()
    {
        /* cannot be instantiated */
        throw new UnsupportedOperationException("cannot be instantiated");
    }

    public static boolean isShow = true;


    /**
     * 显示自定义的toast
     * @param context
     * @param message   显示的内容
     */
//    public static void showCustomToast(Context context, CharSequence message)
//    {
//        Toast toast = new Toast(context);
//        toast.setDuration(Toast.LENGTH_SHORT);
//        View toastShowView = LayoutInflater.from(context).inflate(R.layout.toast_normal,null);
//
//
//        LinearLayout llContainer = (LinearLayout) toastShowView.findViewById(R.id.ll_container);
//
//
//
//        TextView tvTip = (TextView) toastShowView.findViewById(R.id.tv_tip);
//        tvTip.setText(message);
//        toast.setView(toastShowView);
//        toast.setGravity(Gravity.CENTER,0,0);
//
//        // Get the screen size with unit pixels.
//        WindowManager wm = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
//        DisplayMetrics outMetrics = new DisplayMetrics();
//        wm.getDefaultDisplay().getMetrics(outMetrics);
//
//        LinearLayout.LayoutParams vlp = new LinearLayout.LayoutParams(outMetrics.widthPixels, outMetrics.heightPixels);
//        vlp.setMargins(0, 0, 0, 0);
//
//        llContainer.setLayoutParams(vlp);
//
//        toast.show();
//    }

    /**
     * 短时间显示Toast
     *
     * @param context
     * @param message
     */
    public static void showShort(Context context, CharSequence message)
    {
        if (isShow)
            Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
    }

    /**
     * 短时间显示Toast
     *
     * @param context
     * @param message
     */
    public static void showShort(Context context, int message)
    {
        if (isShow)
            Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
    }

    /**
     * 长时间显示Toast
     *
     * @param context
     * @param message
     */
    public static void showLong(Context context, CharSequence message)
    {
        if (isShow)
            Toast.makeText(context, message, Toast.LENGTH_LONG).show();
    }

    /**
     * 长时间显示Toast
     *
     * @param context
     * @param message
     */
    public static void showLong(Context context, int message)
    {
        if (isShow)
            Toast.makeText(context, message, Toast.LENGTH_LONG).show();
    }

    /**
     * 自定义显示Toast时间
     *
     * @param context
     * @param message
     * @param duration
     */
    public static void show(Context context, CharSequence message, int duration)
    {
        if (isShow)
            Toast.makeText(context, message, duration).show();
    }

    /**
     * 自定义显示Toast时间
     *
     * @param context
     * @param message
     * @param duration
     */
    public static void show(Context context, int message, int duration)
    {
        if (isShow)
            Toast.makeText(context, message, duration).show();
    }

}
